Most video coding applications constrain the encoder to compress the input video at a given target bit rate. To accomplish the same, the encoder uses a rate control system. A rate control system allocates a number of bits to each picture in the input video source and adjusts encoding parameters to match the allocated number of bits. The performance of a rate control system is measured by the accuracy in meeting the target bit rate and the visual quality of the compressed video. For example, in video coding standards such as the International Organization for Standardization/International Electrotechnical Commission (ISO/IEC) Moving Picture Experts Group-2 (MPEG-2) Standard, the ISO/IEC Moving Picture Experts Group-4 (MPEG-4) Part 10 Advanced Video Coding (AVC) standard/International Telecommunication Union, Telecommunication Sector (ITU-T) H.264 Recommendation (hereinafter the “MPEG-4 AVC Standard”), and the Society of Motion Picture and Television Engineers (SMPTE) Video Codec-1 Standard (hereinafter the “VC-1 Standard”), several quantization parameters, such as the quantization step size, the rounding offset, and the quantization matrix, are capable of influencing the bit rate.
An example of a video quantization process in accordance with the MPEG-4 AVC Standard will now be described. Mathematically, in the encoder, the transformed coefficients are quantized as follows:
                              Z          =                                    ⌊                                                                                        W                                                        q                                +                s                            ⌋                        ·                          sgn              ⁡                              (                W                )                                                    ,                            (        1        )            where W denotes the transformed coefficient, Z denotes a quantization level to which the transformed coefficient is quantized to, q denotes the quantization step size, and s denotes the rounding offset. The function └ ℑ rounds a value to the nearest integer, and the function sgn(.) returns the sign of a signal. When the quantization matrix is applied, the coefficients are scaled first before the quantization process at the encoder. The range of W where it is quantized to 0 is called the deadzone. In this particular case, the deadzone is Δ=2×(1−s)×q. At the decoder, the quantization level Z is reconstructed to the signal W′. This is called inverse quantization and is described mathematically as follows:W′=q·Z.  (2)
A rate control algorithm mainly adjusts the quantization parameters to obtain the target number of bits. The rate control is considered to be accurate when the number of bits used for some time interval is close or equal to the allocated number of bits for this time interval. The specific time interval used to measure the rate control accuracy is defined depending on the application. In some applications, the bit rate is preferred to be accurate on a picture level. In other applications such as broadcast, the bit rate should be accurate over a few frames due to the channel bandwidth constraint. Moreover, in some other applications such as digital video disk (DVD) authoring, the bit rate accuracy is often measured for the entire sequence and is considered accurate when the number of bits consumed by the entire movie meets the requirement.
Existing rate control algorithms usually assume the rounding offset and quantization matrix are constant and they only adjust the quantization step size. The quantization step sizes have only a finite number of choices. They are represented by quantization indices, which are embedded in the encoded bitstream and conveyed to the decoder for reconstructing the video. With a limited number of quantization step sizes to choose from, existing rate control algorithms can hardly achieve very accurate control without loss of quality. Loss of quality due to the rate control algorithm is often seen as quality inconsistence within the picture or across the pictures. Pictures with lower quality may include visible artifacts that cause part of the picture to be displayed distorted.
To improve the rate control accuracy for a picture, a common approach in existing algorithms is to apply macroblock-level (MB-level) rate control. In accordance with the prior art, a ρ-domain rate control method has been used. A ρ-domain rate control method assumes a linear relation between ρ and R, where ρ denotes the percentage of zero coefficients among the quantized transformed coefficients for an encoded region, and R denotes the number of bits used for encoding the region. Mathematically, a linear rate model is represented as follows:R(ρ)=θ(1−ρ)+Rc,  (3)where Rc denotes the number of non-texture bits used for encoding a region, and θ denotes a constant.
Note that ρ monotonically increases with the quantization step size q, which implies that there is a one-to-one mapping between them. Therefore, given the target number of bits R, the estimated parameters θ and Rc, a ρ-domain rate control method obtains the value of ρ and, therefore, the quantization step size q, based on the one-to-one ρ-q mapping.
Often the quantization step size q calculated above may not fall into the limited number of quantization step sizes that can be represented by quantization indices in the encoder. One approach is to let the macroblocks within the picture use quantization step sizes around q′, the quantization step size that is closest to q and can be represented by a quantization index. Moreover, the average quantization step size used by the picture is approximately q. In one embodiment, a macroblock can choose from among several quantization step sizes {q′-Δ1, q′, q′+Δ2}. Another approach is to update θ and Rc after each macroblock is encoded, and calculate q for each macroblock.
Yet another popular rate control algorithm is the TMN8 rate control algorithm. In the TMN8 rate control algorithm, a quantization step size q is first calculated for a picture. The encoder starts encoding macroblocks with q. Then, as more macroblocks are encoded, the rate control model parameters are updated and the quantization step size is updated on a macroblock basis.
One problem with the macroblock-level adjustment is that the quantization step sizes vary among macroblocks. In some cases, the difference between the quantization parameters can cause inconsistent quality within the picture.
Turning to FIG. 1, a method for rate control for video encoding is indicated generally by the reference numeral 100.
The method 100 includes a start block 105 that passes control to a function block 110. The function block 110 performs and/or otherwise involves an encoding setup, and passes control to a function block 115. The function block 115 initializes rate control parameters, and passes control to a loop limit block 120. The loop limit block 120 performs a loop over each macroblock in a current picture being processed, using a variable i, where i=1, . . . , number (#) of macroblocks in the picture, and passes control to a function block 125. The function block 125 calculates the quantization step size qi for macroblock i, and passes control to a function block 130. The function block 130 encodes macroblock i at quantization step size qi, and passes control to a function block 135. The function block 135 updates the rate control model parameters (for example, based on previously encoded macroblocks), and passes control to a loop limit block 140. The loop limit block ends the loop, and passes control to an end block 199.
Hence, the encoding process ends after all macroblocks in the picture are encoded. It is to be appreciated that method 100 of FIG. 1, the rounding offset parameter is constant throughout the encoding process to which applies method 100. It is to be further appreciated that function block 110 may optionally involve the aid of an operator. Moreover, the encoder setup corresponding to function block 110 may involve the setup of the target bit rate as well as the specification of any set of parameters involved in the encoding process.
The quantization step sizes used by all macroblocks, {qi}i=1, . . . , # of MBs may vary significantly and cause quality inconsistence within the picture. To obtain more consistent quality in the picture, the encoder can choose to limit the dynamic range of the quantization step size. As a result, the number of bits that a picture spends may differ significantly from the target one.